"""
营销相关接口:
Mermerchant_Order:订单相关接口
Mermerchant_RefundOrder:退款订单相关接口
"""
import time

import requests

from base.base_requests import MerRequests
from base.base_url import MerorderUrl


class Mer_merchant_Order:
    def __init__(self):
        pass

    def mer_merchant_order_list(self):
        """
        订单列表
        """
        headers = {


            'authori-zation': 'merchant70821bc9a53d40ab9bd2203fe98d78ce',
            }

        params = {
            'status': 'all',
            'dateLimit': '',
            'orderNo': '',
            'page': '1',
            'limit': '20',
            'type': '',
            'searchType': 'all',
            'content': '',
            'temp': '1761812501',
        }
        response = requests.get(
            'https://api.admin.merchant.java.crmeb.net/api/admin/merchant/order/list',
            params=params,
            headers=headers,
        )
        return response.json()
    def mer_merchant_order_verification(self):
        """
        订单核销
        """
        headers = {


            'authori-zation': 'merchant70821bc9a53d40ab9bd2203fe98d78ce',
            'content-type': 'application/json',
            }

        json_data = {
            'verifyCode': '',
        }

        response = requests.post(
            'https://api.admin.merchant.java.crmeb.net/api/admin/merchant/order/verification',
            headers=headers,
            json=json_data,
        )

    def mer_merchant_order_excel(self):
        """
        订单导出
        """
        headers = {


            'authori-zation': 'merchant70821bc9a53d40ab9bd2203fe98d78ce',
            }

        params = {
            'dateLimit': '',
            'orderNo': '',
            'status': 'all',
            'type': '',
            'temp': '1761812563',
        }

        response = requests.get(
            'https://api.admin.merchant.java.crmeb.net/api/admin/merchant/export/order/excel',
            params=params,
            headers=headers,
        )


class Mer_merchant_RefundOrder(MerRequests, MerorderUrl):

    def mer_merchant_refundorder_list(self, refundOrderNo: str = 'RE376173400891589539607'):
        """
        退款订单列表
        """
        params = {
            'refundStatus': '9',
            'dateLimit': '',
            'orderNo': '',
            'refundOrderNo': refundOrderNo,
            'page': '1',
            'limit': '20',
            'searchType': 'all',
            'content': '',
            'trackingNumber': '',
            'temp': str(int(time.time() * 1000)),
        }

        return self._get(self.mer_merchant_refundorder_list.__name__, url = self._MER_REFUNDORDER_LIST, params=params)
    def mer_merchant_refundorder_detail(self, refundOrderNo: str = 'RE378171697534302055485'):
        """
        退款订单详情
        """
        params = {
            'temp': str(int(time.time() * 1000)),
        }
        detail_url = f"{self._MER_REFUNDORDER_DETAIL}/{refundOrderNo}"
        return self._get(self.mer_merchant_refundorder_detail.__name__, url = detail_url, params=params)

    def mer_merchant_refundorder_mark(self, remark: str = 'aaa', refundOrderNo: str = 'RE378171697534302055485'):
        """
        退款订单备注
        """
        json_data = {
            'remark': remark,
            'refundOrderNo': refundOrderNo,
        }
        mark_url = self._MER_REFUNDORDER_MARK
        return self._post(self.mer_merchant_refundorder_mark.__name__, url=mark_url, data=json_data)
if __name__ == '__main__':
    mer_rd = Mer_merchant_RefundOrder()

    # 调用各个方法
    # print("退款订单列表：", mer_rd.mer_merchant_refundorder_list())
    # print("退款订单详情：", mer_rd.mer_merchant_refundorder_detail())
    print("退款订单备注：", mer_rd.mer_merchant_refundorder_mark())
